using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class EffectElementDecoator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            EffectElement data = target as EffectElement;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.elementId = ValueObject.Value<int>(value);
                    break;
                case 2:
                    data.skillId = ValueObject.Value<int>(value);
                    break;
                case 3:
                    data.skillLv = ValueObject.Value<int>(value);
                    break;
                case 4:
                    data.amount = ValueObject.Value<int>(value);
                    break;
                case 5:
                    data.source = (MapUnit) value;
                    break;
                case 6:
                    data.castPlayerId = ValueObject.Value<long>(value);
                    break;
                case 7:
                    data.normalAttackType = (NormalAttackType) value;
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            EffectElement data = target as EffectElement;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return ValueObject.Get(data.elementId);
                case 2:
                    return ValueObject.Get(data.skillId);
                case 3:
                    return ValueObject.Get(data.skillLv);
                case 4:
                    return ValueObject.Get(data.amount);
                case 5:
                    return data.source;
                case 6:
                    return ValueObject.Get(data.castPlayerId);
                case 7:
                    return data.normalAttackType;
            }

            return null;
        }
    }
}